<template>
  <el-card>
    <div>
      <!-- 面包屑 -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item to="/home"><i class="el-icon-house"></i> 首页</el-breadcrumb-item>
        <el-breadcrumb-item>权限管理</el-breadcrumb-item>
        <el-breadcrumb-item>角色列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <el-col :offset="22">
      <el-button type="primary">添加角色</el-button>
    </el-col>
    <el-table :data="rolelist"
              border
              stripe>
      <el-table-column type="expand">
        <template slot-scope="scope">
          <el-row v-for="item1 in scope.row.children"
                  :key="item1.id">
            <!-- 一级权限 -->
            <el-col :span="5">
              <el-tag>{{item1.authName}}</el-tag>
              <i class="el-icon-caret-right"></i>
            </el-col>
            <!-- 二级权限 -->
            <el-col :span="19">
              <el-row>
                <el-col></el-col>
                <el-col></el-col>
              </el-row>
            </el-col>
          </el-row>
        </template>
      </el-table-column>
      <el-table-column type="index"></el-table-column>
      <el-table-column prop="roleName"
                       label="角色名称">
      </el-table-column>
      <el-table-column prop="roleDesc"
                       label="角色描述">
      </el-table-column>
      <el-table-column label="操作"
                       width="180px">
        <template>
          <!-- 修改按钮 -->
          <el-button type="primary"
                     icon="el-icon-edit"
                     size="mini">
          </el-button>
          <!-- 删除按钮 -->
          <el-button type="danger"
                     icon="el-icon-delete"
                     size="mini">
          </el-button>
          <!-- 分类角色按钮 -->
          <el-tooltip effect="dark"
                      content="分配角色"
                      placement="top"
                      :enterable="false">
            <el-button type="warning"
                       icon="el-icon-setting"
                       size="mini">
            </el-button>
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
  </el-card>

</template>

<script>
export default {
  data () {
    return {
      rolelist: []
    }
  },
  created () {
    this.getRolesList()
  },
  methods: {
    async getRolesList () {
      const { data: res } = await this.$http.get('roles')
      if (res.meta.status !== 200) {
        return this.$message.error('获取数据失败')
      }
      this.rolelist = res.data
      console.log(this.rolelist)
    }
  }
}
</script>

<style>

</style>
